#ifndef REQUESTDESCRIPTOR_H_
#define REQUESTDESCRIPTOR_H_

#include "scHeader.h"
#include "Request.h"
#include <QString>

namespace sybilpm
{
/**
 * Describes what data to be retrieved from the server
 * or how the sent data to be interpreted.
 */
class RequestDescriptor : public std::multimap<int, Request>
{
public:
	static QString getTestUrl();
	RequestDescriptor();
	RequestDescriptor(const Request & request);
	virtual ~RequestDescriptor();
	unsigned long getTransId() const {return transId;}
	void setTransId(unsigned long transactionId) {transId=transactionId;}
	void eraseInc(RequestDescriptor::iterator & it);
	std::string toString() const;
	/**
	 * Merge in all requests of additionalRequ.
	 */
	void include(const RequestDescriptor & additionalRequ);
	/**
	 * Merge in the additional request.
	 */
	void include(const Request & newRequ);
	bool isUpdate() const {return update;}
	QString getUrl(bool encodeParam) const;
	QBuffer * createParamsBuffer() const;

private:
	void toXml(QXmlStreamWriter * writer) const;
	unsigned long transId;
	bool update;
};

} // namespace sybilpm

namespace std
{
ostream& operator<< (ostream& out, const sybilpm::RequestDescriptor & requDesc);
}

#endif /* REQUESTDESCRIPTOR_H_ */
